package android.framework.sample;

import roboguice.inject.InjectView;
import sshason.android.framework.R;
import android.content.Context;
import android.framework.binding.BindableEditText;
import android.framework.binding.Binding;
import android.framework.binding.BindingTextView;
import android.framework.paging.BaseViewInitializer;
import android.framework.reflaction.annotation.OnClickListenerInjectionAnnotation;
import android.framework.rpc.ProxyInvokeHandler;
import android.framework.rpc.ServerDetails;
import android.util.Log;
import android.view.View;

public class Page1 extends BaseViewInitializer<Page1ViewModel> {

	private Page1ViewModel viewModel;
	
	@InjectView(R.id.txtMain)
	private BindingTextView bindingTextView; 
	
	@InjectView(R.id.editText1)
	private BindableEditText editText1;
	
	public Page1(Context context, int layout) {
		super(context, layout);
	}

	@Override
	public void init(View view) {
		viewModel.name.setText("page1 after init");
	}

	
	@OnClickListenerInjectionAnnotation(R.id.button1)
	public void onClick(View v) {
		bindingTextView.setText("after click");
		viewModel.name.setText("Shahar");
		
		new Thread(new Runnable() {
			public void run() {
				ServerDetails serverDetails = new ServerDetails();
				serverDetails.ServerAddress = "http://10.0.0.6/androidCommunication/";
				Contract proxy = ProxyInvokeHandler.CreateInstace(Contract.class, serverDetails);
				//int sum = proxy.sum(1, 2, "asdas");
				//String name = proxy.getName();
				String[] cities = proxy.getCities(new String[]{"Israel", "USA"});
				Log.i("test", cities.toString());
			}
		}).start();
			
		
		
		
	}

//	@Override
//	protected void binding() {
//		Binding.attached(viewModel.name, bindingTextView, editText1);
//	}

}
